package com.learning.enummap;

import java.util.EnumMap;
import java.util.Iterator;

public class EnumMapExample {
	enum STATE {
		NEW, RUNNING, WAITING, FINISHED;
	};

	public static void main(String[] args) {
		EnumMap<STATE, String> stateMap = new EnumMap<STATE, String>(
				STATE.class);

		// Java EnumMap Example 2:
		// putting values inside EnumMap in Java
		// we are inserting Enum keys on different order than their natural
		// order
		stateMap.put(STATE.RUNNING, "Program is running");
		stateMap.put(STATE.WAITING, "Program is waiting");
		stateMap.put(STATE.NEW, "Program has just created");
		stateMap.put(STATE.FINISHED, "Program has finished");
		Iterator<STATE> enumKeySet = stateMap.keySet().iterator();
		while (enumKeySet.hasNext()) {
			STATE currentState = enumKeySet.next();
			System.out.println("key : " + currentState + " value : "
					+ stateMap.get(currentState));
		}

		// Java EnumMap Example 7: checking if EnumMap contains a particular key
		System.out.println("Does stateMap has :" + STATE.NEW + " : "
				+ stateMap.containsKey(STATE.NEW));

		// Java EnumMap Example 8: checking if EnumMap contains a particular
		// value
		System.out.println("Does stateMap has :" + STATE.NEW + " : "
				+ stateMap.containsValue(null));

	}
}
